/**
 * AluiCommons -  http://code.google.com/p/alui-toolbox/
 * Copyright (c) 2008-2009
 * by Fabien Sanglier
 * 
 * This file is part of AluiCommons.
 * 
 * AluiCommons is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * AluiCommons is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with AluiCommons.  If not, see <http://www.gnu.org/licenses/>.
 * 
 */

using System;
using System.Data;
using System.Configuration;

namespace AluiServerLib.Helper
{
    public class ArrayHelper
    {
        public static int[] ConvertToIntArray(string[] stringarray)
        {
            int[] intarray = null;
            if (null != stringarray)
            {
                intarray = new int[stringarray.Length];
                for (int i = 0; i < stringarray.Length; i++)
                {
                    try
                    {
                        intarray[i] = int.Parse(stringarray[i]);
                    }
                    catch (Exception exc)
                    {
                        intarray[i] = 0;
                    }
                }
            }
            return intarray;
        }

        public static string[] ConvertToStringArray(int[] intarray)
        {
            string[] stringarray = null;
            if (null != intarray)
            {
                stringarray = new string[intarray.Length];
                for (int i = 0; i < intarray.Length; i++)
                {
                    try
                    {
                        stringarray[i] = intarray[i].ToString();
                    }
                    catch (Exception exc)
                    {
                        stringarray[i] = "";
                    }
                }
            }
            return stringarray;
        }
    }
}
